#include <bits/stdc++.h>
using namespace std;

int p[100005];
int q[100005];

int main()
{
	freopen("arena.in","r",stdin);
	freopen("arena.out","w",stdout);
	ios::sync_with_stdio(false);
	int t, n, m, k, r, a, b, c, d;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> p[i];
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> q[i];
	}
	cin >> k;
	cin >> r;
	cin >> t;
	for(int i = 1; i <= t; i++)
	{
		cin >> a >> b >> c >> d;
	}
	if(t == 1)
	{
		cout << "1";
	}
	else
	{
		for(int i = 1; i <= t; i++)
		{
			cout << "1" << endl;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
